package com.varian.system.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;

import java.util.List;

/**
 * @author ben
 * @since 2025/2/6
 */
@Data
@Schema(title = "部门绘图视图对象")
public class SysDeptDiagramVO {

    @Schema(title = "节点列表")
    private List<Node> nodes;

    @Schema(title = "边列表")
    private List<Edge> edges;

    @Data
    @Schema(title = "部门节点")
    @NoArgsConstructor
    public static class Node {
        @Schema(title = "节点id")
        private Long id;
        @Schema(title = "节点数据")
        private NodeData data;

        public Node(Long id, String deptName, String deptCode, Integer deptLevel, Integer rightValue, Integer leftValue) {
            this.id = id;
            this.data = new NodeData(deptName, deptCode, deptLevel, rightValue, leftValue);
        }

        @Data
        @NoArgsConstructor
        @AllArgsConstructor
        @Schema(title = "节点数据")
        public static class NodeData {
            @Schema(title = "部门名称")
            private String deptName;
            @Schema(title = "部门编码")
            private String deptCode;
            @Schema(title = "层级")
            private Integer deptLevel;
            @Schema(title = "右值")
            private Integer rightValue;
            @Schema(title = "左值")
            private Integer leftValue;
        }
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Schema(title = "部门关系边")
    public static class Edge {
        @Schema(title = "起始节点id")
        private Long source;
        @Schema(title = "结束节点id")
        private Long target;
    }
}
